
import ac = module("utils/commons/array-collection");
	
/**
	* The list of valid attachment levels for cross-sectional components.
	* 
	* @author Xavier Sosnovsky, Anthony Morel
	*/
export class XSAttachmentLevel
{
	/*==============================Fields================================*/
		
	private static _instance:XSAttachmentLevel;
		
	private static _attachmentLevels:ac.ArrayCollection<string>;
		
	/*============================Constants===============================*/
		
	/**
	    * Data set level.
	    */
	public static XSDATASET:string = "XSDataSet";
	    
	/**
	    * Group level.
	    */
	public static GROUP:string = "Group";
	    
	/**
	    * Series level.
	    */
	public static SECTION:string = "Section";
	    
	/**
	    * Observation level.
	    */
	public static XSOBSERVATION:string = "XSObservation";
	    
	/*===========================Constructor==============================*/
	    
	constructor(enforcer:SingletonEnforcer)
	{
	}
		
	/*==========================Public methods============================*/
	    
	/**
	    * Whether the supplied cross-sectional attachment level is in the list 3
	    * of valid SDMX attachment levels.
	    * 
	    * @return true if the supplied cross-sectional attachmentLevel is in 
	    * the list of valid SDMX attachment levels, false otherwise.
	    */ 
	public static contains(attachmentLevel:string):bool {
	    return this.createAttachmentLevelList().contains(attachmentLevel);
	}
    
    /*=========================Private methods============================*/
    
    private static createAttachmentLevelList(): ac.ArrayCollection<string> {
	    if (null == this._instance) {
	    	this._instance = new XSAttachmentLevel(new SingletonEnforcer());
            this._attachmentLevels = new ac.ArrayCollection<string>();
            this._attachmentLevels.addItem(XSAttachmentLevel.XSDATASET);
            this._attachmentLevels.addItem(XSAttachmentLevel.GROUP);
            this._attachmentLevels.addItem(XSAttachmentLevel.SECTION);
            this._attachmentLevels.addItem(XSAttachmentLevel.XSOBSERVATION);
	    }
		return this._attachmentLevels;
	}
}

export class SingletonEnforcer {
}